
package com.scs.application.modules.upms.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.scs.application.core.service.BaseServiceImpl;
import com.scs.application.core.utils.StringUtils;
import com.scs.application.modules.upms.entity.OauthClientDetails;
import com.scs.application.modules.upms.mapper.OauthClientDetailsMapper;
import com.scs.application.modules.upms.request.OauthClientDetailsQueryRequest;
import com.scs.application.modules.upms.service.OauthClientDetailsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* 客户端 service 实现
*/
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class OauthClientDetailsServiceImpl extends BaseServiceImpl<OauthClientDetailsMapper, OauthClientDetails> implements OauthClientDetailsService {

    @Override
    public List<OauthClientDetails> list(OauthClientDetailsQueryRequest request) {
        List<OauthClientDetails> list = this.list(Wrappers.<OauthClientDetails>query()
                .eq(StringUtils.isNotBlank(request.getClientId()), "client_id", request.getClientId())
            .orderByDesc("client_id")
        );
        return list;
    }

    @Override
    public IPage<OauthClientDetails> page(OauthClientDetailsQueryRequest request) {
        IPage page = this.page(request.getPage(), Wrappers.<OauthClientDetails>query()
                .eq(StringUtils.isNotBlank(request.getClientId()), "client_id", request.getClientId())
            .orderByDesc("client_id")
        );
        return page;
    }
}
